package com.autoMobile.util;

import com.autoMobile.bean.Vehicle;
import com.autoMobile.bean.auto_management;
import com.autoMobile.bean.userBean;
import com.autoMobile.dao.VehicleDao;
import com.autoMobile.dao.auto_managementDao;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

public class listData {
    public static void vehList(HttpServletRequest request, HttpServletResponse response,ServletContext context){
        List<Vehicle> list = VehicleDao.getAllVehicles();
        context.setAttribute("VehList",list);
        List<List> VehListKy = new ArrayList<List>();
        List<Integer> VehListint = new ArrayList<Integer>();
        int sy=0;
        int wx=0;
        int ky=0;
        for (Vehicle veh:list) {
            List<String> VehZt =new ArrayList<String>();
            if (veh.getStatus().equals("可用")){
                VehZt.add(veh.getLicensePlate());
                VehZt.add(veh.getModel());
                VehListKy.add(VehZt);
                ky=ky+1;
            }
            if (veh.getStatus().equals("使用中")) sy=sy+1;
            if (veh.getStatus().equals("维修中")) wx=wx+1;

        }
        VehListint.add(sy);
        VehListint.add(wx);
        VehListint.add(ky);

        context.setAttribute("VehInt",VehListint);
        context.setAttribute("VehKy",VehListKy);
    }
    public static void autoList(HttpServletRequest request, HttpServletResponse response,ServletContext context){
        List<auto_management> list = auto_managementDao.getAutoManagement();
        int i = list.size();
        context.setAttribute("autoListI",i);
        context.setAttribute("autoList",list);
    }

}
